// Extension

import 'package:gd_assistant/util/RelativeDateFormat.dart';

class Extension {
  User user;
  Order order;
  Doctor doctor;
  Evaluation evaluation;

  Extension({this.user, this.order, this.doctor, this.evaluation});

  Extension.fromJson(Map<String, dynamic> json) {
    user = json['user'] != null ? new User.fromJson(json['user']) : null;
    order = json['order'] != null ? new Order.fromJson(json['order']) : null;
    doctor =
        json['doctor'] != null ? new Doctor.fromJson(json['doctor']) : null;
    evaluation = json['evaluation'] != null
    ? new Evaluation.fromJson(json['evaluation'])
    : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.user != null) {
      data['user'] = this.user.toJson();
    }
    if (this.order != null) {
      data['order'] = this.order.toJson();
    }
    if (this.doctor != null) {
      data['doctor'] = this.doctor.toJson();
    }
    if (this.evaluation != null) {
      data['evaluation'] = this.evaluation.toJson();
    }
    return data;
  }
}

class User {
  String avatar;
  String name;
  String phoneNum;
  String age;
  String sex;
  String sid;
  String costType;

  User({this.avatar, this.name, this.phoneNum, this.age, this.sex, this.sid, this.costType});

  User.fromJson(Map<String, dynamic> json) {
    avatar = json['avatar'];
    name = json['name'];
    phoneNum = json['phoneNum'];
    age = json['age'];
    sex = json['sex'];
    sid = json['_id'];
    costType = json['costType'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['avatar'] = this.avatar;
    data['name'] = this.name;
    data['phoneNum'] = this.phoneNum;
    data['age'] = this.age;
    data['sex'] = this.sex;
    data['_id'] = this.sid;
    data['costType'] = this.costType;
    return data;
  }
}

class Order {
  String orderId;
  String servicePackageOrderId;
  List<String> items;
  String desc;
  int workTime;
  String workTimeStr;
  String address;
  int status;
  String instructions;
  List<String> checklistImgs;
  String medicalNumber;
  String weekStr;
  int price;
  bool isCancle;
  bool isEvaluate;
  String patientName;
  int babyBirth;
  int expectedDate;
  int lastMenstruation;

  Order(
      {this.orderId,
      this.servicePackageOrderId,
      this.items,
      this.desc,
      this.workTime,
      this.workTimeStr,
      this.address,
      this.status,
      this.instructions,
      this.checklistImgs,
      this.medicalNumber,
      this.weekStr,
      this.price,
      this.isCancle,
      this.isEvaluate,
      this.patientName,
      this.babyBirth,
      this.expectedDate,
      this.lastMenstruation});

  Order.fromJson(Map<String, dynamic> json) {
    orderId = json['orderId'];
    servicePackageOrderId = json['servicePackageOrderId'];
    items = json['items'].cast<String>();
    desc = json['desc'];
    workTime = json['workTime'];
    workTimeStr = json['workTimeStr'];
    address = json['address'];
    status = json['status'];
    instructions = json['instructions'];
    checklistImgs = json['checklist_imgs'].cast<String>();
    medicalNumber = json['medical_number'];
    weekStr = json['week_str'];
    price = json['price'];
    isCancle = json['is_cancle'];
    isEvaluate = json['is_evaluate'];
    patientName = json['patientName'];
    babyBirth = json['babyBirth'];
    expectedDate = json['expectedDate'];
    lastMenstruation = json['last_menstruation'];
   
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['orderId'] = this.orderId;
    data['servicePackageOrderId'] = this.servicePackageOrderId;
    data['items'] = this.items;
    data['desc'] = this.desc;
    data['workTime'] = this.workTime;
    data['workTimeStr'] = this.workTimeStr;
    data['address'] = this.address;
    data['status'] = this.status;
    data['instructions'] = this.instructions;
    data['checklist_imgs'] = this.checklistImgs;
    data['medical_number'] = this.medicalNumber;
    data['week_str'] = this.weekStr;
    data['price'] = this.price;
    data['is_cancle'] = this.isCancle;
    data['is_evaluate'] = this.isEvaluate;
    data['patientName'] = this.patientName;
    data['babyBirth'] = this.babyBirth;
    data['expectedDate'] = this.expectedDate;
    data['last_menstruation'] = this.lastMenstruation;
    return data;
  }
}

class Doctor {
  String sId;
  String name;
  String title;
  String hospital;
  String department;
  String avatar;

  Doctor({this.sId, 
      this.name,
      this.title, 
      this.hospital, 
      this.department, 
      this.avatar});

  Doctor.fromJson(Map<String, dynamic> json) {
    sId = json['_id'];
    name = json['name'];
    title = json['title'];
    hospital = json['hospital'];
    department = json['department'];
    avatar = json['avatar'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['_id'] = this.sId;
    data['name'] = this.name;
    data['title'] = this.title;
    data['hospital'] = this.hospital;
    data['department'] = this.department;
    data['avatar'] = this.avatar;
    return data;
  }
}


class Evaluation {
  String doctorId;
  String doctorName;
  String doctorAvatar;
  int doctorStarRating;
  String doctorEvaluationDesc;
  String assistantId;
  String assistantName;
  String assistantAvatar;
  int assistantStarRating;
  String assistantEvaluationDesc;
  bool isShow;

  Evaluation(
      {this.doctorId,
      this.doctorName,
      this.doctorAvatar,
      this.doctorStarRating,
      this.doctorEvaluationDesc,
      this.assistantId,
      this.assistantName,
      this.assistantAvatar,
      this.assistantStarRating,
      this.assistantEvaluationDesc,
      this.isShow});

  Evaluation.fromJson(Map<String, dynamic> json) {
    doctorId = json['doctorId'];
    doctorName = json['doctorName'];
    doctorAvatar = json['doctorAvatar'];
    doctorStarRating = json['doctorStarRating'];
    doctorEvaluationDesc = json['doctorEvaluationDesc'];
    assistantId = json['assistantId'];
    assistantName = json['assistantName'];
    assistantAvatar = json['assistantAvatar'];
    assistantStarRating = json['assistantStarRating'];
    assistantEvaluationDesc = json['assistantEvaluationDesc'];
    isShow = json['isShow'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['doctorId'] = this.doctorId;
    data['doctorName'] = this.doctorName;
    data['doctorAvatar'] = this.doctorAvatar;
    data['doctorStarRating'] = this.doctorStarRating;
    data['doctorEvaluationDesc'] = this.doctorEvaluationDesc;
    data['assistantId'] = this.assistantId;
    data['assistantName'] = this.assistantName;
    data['assistantAvatar'] = this.assistantAvatar;
    data['assistantStarRating'] = this.assistantStarRating;
    data['assistantEvaluationDesc'] = this.assistantEvaluationDesc;
    data['isShow'] = this.isShow;
    return data;
  }
}


class AppointmentTime {
  int visitPlanDate;
  int visitPlanPeriod;
  int visitPlanWeek;
  String visitPlanPlace;
  String dateString;

  AppointmentTime(
      {this.visitPlanDate,
      this.visitPlanPeriod,
      this.visitPlanWeek,
      this.visitPlanPlace});

  AppointmentTime.fromJson(Map<String, dynamic> json) {
    visitPlanDate = json['visitPlanDate'];
    visitPlanPeriod = json['visitPlanPeriod'];
    visitPlanWeek = json['visitPlanWeek'];
    visitPlanPlace = json['visitPlanPlace'];
    dateString = RelativeDateFormat.MDformat(visitPlanDate);
    switch (visitPlanWeek) {
        case 7:
          dateString += " (周日) ";
          break;
        case 1:
          dateString += " (周一) ";
          break;
        case 2:
          dateString += " (周二) ";
          break;
        case 3:
          dateString += " (周三) ";
          break;
        case 4:
          dateString += " (周四) ";
          break;
        case 5:
          dateString += " (周五) ";
          break;
        case 6:
          dateString += " (周六) ";
          break;          
        default:
      }
    switch (visitPlanPeriod) {
      case 1:
        dateString += "上午";
        break;
      case 2:
        dateString += "下午";
        break;
      case 3:
        dateString += "晚间";
        break;
      default:
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['visitPlanDate'] = this.visitPlanDate;
    data['visitPlanPeriod'] = this.visitPlanPeriod;
    data['visitPlanWeek'] = this.visitPlanWeek;
    data['visitPlanPlace'] = this.visitPlanPlace;
    return data;
  }
}

class WorkTime {
  int price;
  List<String> workTimes;
  List<String> bookedTimes;

  WorkTime({this.price, this.workTimes, this.bookedTimes});

  WorkTime.fromJson(Map<String, dynamic> json) {
    price = json['price'];
    workTimes = json['workTimes'].cast<String>();
    bookedTimes = json['bookedTimes'].cast<String>();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['price'] = this.price;
    data['workTimes'] = this.workTimes;
    data['bookedTimes'] = this.bookedTimes;
    return data;
  }
}

